<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
     function  my(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
     var   random =my(1,10);
    //  console.log(random);
    //  var i=0;
    // while(i<=10)
     while(true)
    {//一直循环用true
        var num=parseInt(prompt('请输入1-10之间的数字，进行游戏'))
       if(num == random){
              alert('恭喜你，猜对了...')
              break;
       }else if(num>random){
            alert('猜大了...');
        }else if(num<random){
            alert('猜小了...')
        }else{
           alert('不能为空')
            
        }
    //    i++;
     }
   </script> 
</body>
</html>